package com.atguigu.day03.homework;

import java.util.Scanner;

public class HomeWork14 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份:");
        int year = sc.nextInt();

        if(year > 0){
            System.out.println("请输入月份:");
            int month = sc.nextInt();
            if(month > 0 && month <= 12){
                System.out.println("请输入日期:");
                int day = sc.nextInt();
                switch (month){
                    case 1,3,5,7,8,10,12:
                        if(day > 0 && day <= 31){
                            System.out.println(year + "年" + month + "月" + day + "日");
                        }else{
                            System.out.println("日期格式错误");
                        }
                        break;
                    case 2:
                        if (year % 4 == 0 && year % 100 != 0 && year % 400 == 0){
                            if(day > 0 && day <= 29){
                                System.out.println(year + "年" + month + "月" + day + "日");
                            }else{
                                System.out.println("日期格式错误");
                            }
                        }else{
                            if(day > 0 && day <= 28){
                                System.out.println(year + "年" + month + "月" + day + "日");
                            }else{
                                System.out.println("日期格式错误");
                            }
                        }
                        break;
                    case 4,6,9,11:
                        if(day > 0 && day <= 30){
                            System.out.println(year + "年" + month + "月" + day + "日");
                        }else{
                            System.out.println("日期格式错误");
                        }
                        break;
                }
            }else{
                System.out.println("月份格式错误");
            }
        }else{
            System.out.println("年份格式错误");
        }
    }
}
